package com.lmq.synchstudy;

public class T6A {
    // 临界资源，多个线程共享访问的资源
    private int num;

    public int getNum() {
        return num;
    }

    public synchronized int genNum() {
        // 首先是计算num+1
        // 把结果赋值给num
        return num++;
    }

    public static void main(String[] args) {
        T6A t6A = new T6A();
        System.out.println(t6A.genNum());
        System.out.println(t6A.getNum());
    }
}
